<?php

	class Pages extends CI_Controller
	{
		public function view($page = 'home')
		{
			$this->load->helper('url');
			$this->load->library('session');
			
			// Page exists
			if (!file_exists('../application/views/pages/'.$page.'.php'))
			{
				show_404();
			}
			
			// Check for session
			if(!$this->session->userdata('logged_in'))
			{
				// Not signed in - show login page
				header('Location: /auth/signin');
			}
			
			// Set up page specific data
			switch($page)
			{
				default:
					$data['title'] = ucfirst($page);
					break;	
			}
			
			// Main navigation
			$data['main_navigation'] = $this->load->view('main-navigation', array('logged_in' => TRUE), true);

			$this->load->view('templates/header', $data);
			$this->load->view('pages/'.$page, $data);
			$this->load->view('templates/footer', $data);
		}
		
		
	}

?>